#!/usr/bin/env python
# -*- coding: utf-8 -*-

#偏函数functools.partial, 可以改变一个函数的签名，一般用于简化函数的调用参数

import functools

def show_args(*args, **kw):
    print(",".join([ "%s=>%s"%(k,v) for k,v in enumerate(args)]+[ "%s=>%s"%(k,v) for k,v in kw.items()]))

show_args('redis','is','nosql','database',host='127.0.0.1', port=6379, db=1) #0=>redis,1=>is,2=>nosql,3=>database,host=>127.0.0.1,port=>6379,db=>1

excute_cmd = functools.partial(show_args, 'redis','is','nosql','database',host='127.0.0.1', port=6379, db=1)
excute_cmd("get key1") #0=>redis,1=>is,2=>nosql,3=>database,4=>get key1,host=>127.0.0.1,port=>6379,db=>1
excute_cmd(cmd="lrange list1 0 -1") #0=>redis,1=>is,2=>nosql,3=>database,host=>127.0.0.1,port=>6379,db=>1,cmd=>lrange list1 0 -1